<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>页面模版</title>
       <script src="/script/vue.js"></script>
    <script type="text/javascript" src="/script/mootools.js"></script>
    <script type="text/javascript" src="/script/mootools-more.js"></script>
    <script type="text/javascript" src="/script/jspxnet.js"></script>
    <script type="text/javascript" src="/script/jspxnet-ui-roc.js"></script>
    <script type="text/javascript" src="/script/codemirror/lib/codemirror.js"></script>
    <link href="/script/codemirror/lib/codemirror.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/script/codemirror/mode/xml/xml.js"></script>
    <script type="text/javascript" src="/script/codemirror/mode/javascript/javascript.js"></script>
    <script type="text/javascript" src="/script/codemirror/mode/css/css.js"></script>
    <script type="text/javascript" src="/script/codemirror/mode/htmlmixed/htmlmixed.js"></script>
    <script type="text/javascript" src="/script/codemirror/mode/htmlembedded/htmlembedded.js"></script>
    <script type="text/javascript" src="/script/codemirror/addon/mode/multiplex.js"></script>
    <link rel="stylesheet" type="text/css" href="/script/jspxnet-ui.css"/>
	<link href="skin/default/main.css" rel="stylesheet" type="text/css"/>
    <link href="skin/default/base.css" rel="stylesheet" type="text/css"/>

<script>
    var app = false;
    var editor = false;
	var id = getUrlParam("id") - 0;
    window.addEvent('domready', function () {
         editor = CodeMirror.fromTextArea($('content'), {
                lineNumbers: true,
                mode: "application/x-ejs",
                indentUnit: 4,
				readOnly:false
         });

		loadData();

		$('saveBtn').addEvent('click', function () {
                var posts = getFormJson("uiTemplateForm");
                posts.id = id;
                posts.content = editor.getValue();
                console.log(posts);
                new Request.ROC({
                    'url': '/devcenter/ui/template/save.jwc', data: posts,
                    onSuccess: function (obj) {
                        if (obj.success == 1) {
                            id = obj.data;
                            new JDialog.Pop({
                                title: '提示信息',
                                message: obj.message
                            }).show();
                        } else {
                            new JDialog.Alert({
                                title: '提示信息',
                                message: obj.message
                            }).show();
                        }
                    }
                }).post();
       });
    });

	function loadData()
    {
         if (!id||id<=0)
         {
               return false;
         }
         new Request.ROC({
                        'url': '/devcenter/ui/template/detail/' + id + '.jwc',
                        onSuccess: function (obj) {
                            if (obj.success) {
								  $('name').set('value',obj.data.name);
								 editor.setValue(obj.data.content);
                            }
                        }
          }).post();
    }
</script>
</head>
<body>
<div class="formContainer mWrap">
    <div class="mTitPanel addBoardLogo">
        页面模版
    </div>
    <div class="addConPanel mConPanel">
        <div id="helpTip"></div>
        <form id="uiTemplateForm" v-cloak>
                    <div class="row">
                        <label class="tit" for="name">名称</label>
                        <div class="con">
                            <input id="name" name="name" type="text" v-model:value="name"/>
                            <span id="nameMsg" class="note"></span>
                        </div>
                    </div>
                    <div class="columnPanel" >
                        <label class="tit" for="content">正文</label>
                        <div class="con">
                            <textarea id="content" name="content" style="width:98%;height:500px;" v-model:value="content"></textarea>
                            <span id="contentMsg" class="note"></span>
                        </div>
                    </div>
            <div class="buttonPanel">
                <button id="saveBtn" name="method" value="save" type="button"class="jDefButton"><i class="jIcoSave"></i>确定</button>
                <input id="id" name="id" type="hidden" :value="id"/>
            </div>
        </form>
    </div>
</div>

</body>
</html>
